//
//  MoneyDetailCell.m
//  MarkPlatform
//
//  Created by 敖然 on 2017/12/20.
//  Copyright © 2017年 AT. All rights reserved.
//

#import "MoneyRecordCell.h"

@interface MoneyRecordCell()

@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *subTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailLabel;
@property (weak, nonatomic) IBOutlet UILabel *flowLabel;

@end;

@implementation MoneyRecordCell

+ (CGFloat)cellHeight {
    return 60.0f;
}

- (void)setModel:(MPRecordModel *)model {
    _model = model;
    switch (_model.feeType) {
        case MPRecordTypeIncomeMark:
            self.iconView.image = [UIImage imageNamed:@"icon_biaozhu_nor"];
            break;
        case MPRecordTypeIncomeReview:
            self.iconView.image = [UIImage imageNamed:@"icon_shenhe_nor"];
            break;
        case MPRecordTypeEnchashment:
            self.iconView.image = [UIImage imageNamed:@"icon_tixian"];
            break;
        default:
            break;
    }
    self.titleLabel.text = _model.feeTypeName;
    self.subTitleLabel.text = [[NSDate dateWithTimeIntervalSince1970:_model.time/1000.0f] stringWithFormat:@"yyyy-MM-dd HH:mm:ss"];
    if (_model.isFeeIncome) {
        self.detailLabel.textColor = [UIColor colorWithRGB:0x4cd94a];
        self.detailLabel.text = [NSString stringWithFormat:@"+%.2f",_model.fee];
    }
    else {
        self.detailLabel.textColor = [UIColor colorWithRGB:0x555555];
        self.detailLabel.text = [NSString stringWithFormat:@"-%.2f",_model.fee];
    }
    self.flowLabel.text = nil;
}

- (void)setCompanyModel:(MPRecordModel *)companyModel {
    _companyModel = companyModel;
    self.iconView.image = _companyModel.isFeeIncome ? [UIImage imageNamed:@"icon_chongzhi"] : [UIImage imageNamed:@"icon_biaozhu_nor"];
    self.titleLabel.text = _companyModel.feeTypeName;
    self.subTitleLabel.text = [[NSDate dateWithTimeIntervalSince1970:_companyModel.time/1000.0f] stringWithFormat:@"yyyy-MM-dd HH:mm:ss"];
    if (_model.isFeeIncome) {
        self.detailLabel.textColor = [UIColor colorWithRGB:0x4cd94a];
        self.detailLabel.text = [NSString stringWithFormat:@"+%.2f",_companyModel.fee];
    }
    else {
        self.detailLabel.textColor = [UIColor colorWithRGB:0x555555];
        self.detailLabel.text = [NSString stringWithFormat:@"-%.2f",_companyModel.fee];
    }
    self.flowLabel.text = [NSString stringWithFormat:@"流水号:%@",SafeDicObj(_companyModel.no)];
}
@end
